import { Token } from "@/types/data"

// 这里封装token的本地存取操作
const TOKEN_KEY = 'geek-99-token'
// 存储
export const setToken = (token: Token) => {
    localStorage.setItem(TOKEN_KEY, JSON.stringify(token))
}

// 获取
export const getToken = () => {
    return JSON.parse(localStorage.getItem(TOKEN_KEY) || '{}')
}

// 删除
export const removeToken = () => {
    localStorage.removeItem(TOKEN_KEY)
}

// 判断有无token   返回 true  Or  false
export const hasToken = () => {
    return !!getToken().token
}
